package com.example.demo.threadPool_countDownLatch.plus;

import com.alibaba.ttl.threadpool.TtlExecutors;

import java.util.concurrent.*;

/**
 * @author peter
 * @Date 2021/8/13 3:39 下午
 * @Classname ThreadpoolConfig
 * @Description 线程池
 */
public class ThreadpoolConfig {

    private static final Integer MAX_POOL_SIZE = 600;

    private static final Integer KEEP_ALIVE_TIME = 60;

    public static final ExecutorService CUSTOMER_EXECUTOR =
            TtlExecutors.getTtlExecutorService(
                    new ThreadPoolExecutor(
                            200,
                            MAX_POOL_SIZE,
                            KEEP_ALIVE_TIME,
                            TimeUnit.SECONDS,
                            new SynchronousQueue<>(),
                            Executors.defaultThreadFactory(),
                            new ThreadPoolExecutor.CallerRunsPolicy()));
}
